#include "Crosshair.h"
#include "World.h"

Crosshair::Crosshair()
{
	this->texture = new Texture();
	this->texture->load("mirilla/crosshair.tga");
}

Crosshair::~Crosshair(void)
{
}

void Crosshair::render()
{
	Matrix44 model_player = World::getInstance()->player->player->model;
	this->model=this->model*model_player;
	glPushMatrix();
	model.set();
	model.setRotation(-90*DEG2RAD, Vector3(0,0,1));
	model.rotate(90*DEG2RAD, Vector3(1,0,0));
	model.traslate(2.4,-40.2,3.5);
	glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );  
	texture->bind();
	glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 
	glDepthMask(GL_FALSE);
	glBegin(GL_QUADS); 
	glVertex2f(0.0,0.0);glTexCoord2f(0.0,0.0);	
	glVertex2f(5,0.0);glTexCoord2f(1.0,0.0);	
	glVertex2f(5,5);glTexCoord2f(1.0,1.0);
	glVertex2f(0.0,5);glTexCoord2f(0.0,1.0);
	glEnd();
	texture->unbind();
	glDisable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);
	glPopMatrix();	
}
